package de.haw.adt.implementation;

import static de.haw.adt.implementation.Values.KILO;
import de.haw.adt.interfaces.IMass;

class Mass extends AbstractPhysicalScalar implements IMass {

	private final double kilogramms;

	private Mass(double kilogramms) {
		this.kilogramms = kilogramms;
	}
	
	@Override
	double getValue() {
		return kilogramms;
	}

	public int compareTo(IMass mass) {
		return Double.compare(this.getKg(), mass.getKg());
	}

	@Override
	public boolean equals(Object o) {
		if (o == this)
			return true;
		if (!(o instanceof Mass))
			return false;
		return this.compareTo((Mass) o) == 0;
	}
	
	public double getKg() {
		return kilogramms;
	}

	public double getT() {
			return kilogramms / KILO;
	}

	public IMass add(IMass mass) {
		return valueOf(this.getKg() + mass.getKg());
	}

	public IMass sub(IMass mass) {
		return valueOf(this.getKg() - mass.getKg());
	}

	public IMass mul(double factor) {
		return valueOf(this.getKg() * factor);
	}

	public IMass div(double factor) {
		return valueOf(this.getKg() / factor);
	}
	
	public static Mass valueOf(double kilogramms) {
		return new Mass(kilogramms);
	}
}
